#include "string-util.h"
#include "MapTest.h"
#include <string>

MapTest::MapTest()
{
    std::string he("he");
    //mTestMap.insert(make_pair(he, 11));
}

MapTest::~MapTest()
{

}

void MapTest::canReturnedIteratorChangeItsMap()
{
    psln(mTestMap["he"]);
    returnIteratorOfMap()->second = 1111;
    psln(mTestMap["he"]);
}

MapTest::TestIter MapTest::returnIteratorOfMap()
{
    return mTestMap.find("he");
}

void MapTest::testInsert()
{
    TestIter iter = mTestMap.find("he");
    if (iter != mTestMap.end()) {
        psln(iter->second);
    }

    mTestMap["he"] = 10000;

    iter = mTestMap.find("he");
    psln(iter->second);

    // following codes won't compile, why?
    /*std::pair<std::string, int> result = mTestMap.insert(make_pair(std::string("he"), 10000));
    psln(result.second);*/
}
